<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: TestAll</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">TestAll</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/test/test_all_rb.html">
                test/test_all.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Test::Unit::TestCase
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">
    <div id="diagram">
      <map id="map" name="map">
  <area shape="rect" coords="39,101,111,149"      href="TestAll.html" alt="TestAll" />
  <area shape="rect" coords="5,5,144,53"      href="Test/Unit/TestCase.html" alt="Test::Unit::TestCase" />
</map>
<img src="../dot/f_19.png" usemap="#map" border="0" alt="dot/f_19.png">
    </div>

    <div id="description">
      <ul>
<li>test_all.rb

</li>
<li>Copyright (C) 2010 Embian Inc.

<p>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
</p>
<p>
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
</p>
<p>
You should have received a copy of the GNU General Public License along
with This program. If not, see &lt;<a
href="http://www.gnu.org/licenses">www.gnu.org/licenses</a>/&gt;.
</p>
</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000043">_get_responses</a>&nbsp;&nbsp;
      <a href="#M000039">setup</a>&nbsp;&nbsp;
      <a href="#M000040">teardown</a>&nbsp;&nbsp;
      <a href="#M000041">test_all</a>&nbsp;&nbsp;
      <a href="#M000042">test_with_realistic_data</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">setup</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
    <span class="ruby-comment cmt"># File test/test_all.rb, line 33</span>
33:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
34:     <span class="ruby-comment cmt">#Do nothing</span>
35:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">teardown</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
    <span class="ruby-comment cmt"># File test/test_all.rb, line 37</span>
37:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">teardown</span>
38:     <span class="ruby-comment cmt">#Do nothing</span>
39:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">test_all</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
    <span class="ruby-comment cmt"># File test/test_all.rb, line 41</span>
41:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_all</span>
42:     <span class="ruby-comment cmt">#Call Other Unit Tests</span>
43:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000042" class="method-detail">
        <a name="M000042"></a>

        <div class="method-heading">
          <a href="#M000042" class="method-signature">
          <span class="method-name">test_with_realistic_data</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000042-source">
<pre>
     <span class="ruby-comment cmt"># File test/test_all.rb, line 45</span>
 45:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_with_realistic_data</span>
 46: ??
 47: 
 48:     <span class="ruby-comment cmt"># Read examinee item responses from file mondat.dat.</span>
 49:     <span class="ruby-comment cmt"># Each record contains the responses to </span>
 50:     <span class="ruby-comment cmt"># 60 items for an examinee in columns 2-61.</span>
 51:     <span class="ruby-identifier">items</span> = []
 52:     <span class="ruby-value">60</span>.<span class="ruby-identifier">times</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">no</span><span class="ruby-operator">|</span>
 53:       <span class="ruby-identifier">items</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IRTItem</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;id#{no+1}&quot;</span>)
 54:     <span class="ruby-keyword kw">end</span>
 55:     
 56:     <span class="ruby-comment cmt"># The first 24 items are the unique items on</span>
 57:     <span class="ruby-comment cmt"># Form Y, the second 12 items are common items,</span>
 58:     <span class="ruby-comment cmt"># and the last 24 items are unique items on</span>
 59:     <span class="ruby-comment cmt"># Form X. An integer in column 1 gives</span>
 60:     <span class="ruby-comment cmt"># the examinee group: 1 for examinees</span>
 61:     <span class="ruby-comment cmt"># who took Form Y, and 2 for examinees</span>
 62:     <span class="ruby-comment cmt"># who took Form X</span>
 63:     
 64:     <span class="ruby-identifier">examinees</span> = []
 65:     <span class="ruby-identifier">no</span> = <span class="ruby-value">1</span>
 66:     <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">'./mondat.dat'</span>, <span class="ruby-value str">'r'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
 67:       <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gets</span>
 68:         <span class="ruby-identifier">group</span> = <span class="ruby-identifier">line</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span>.<span class="ruby-identifier">to_i</span>
 69:         <span class="ruby-identifier">responses</span> = <span class="ruby-identifier">_get_responses</span>(<span class="ruby-identifier">line</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>)])
 70:         <span class="ruby-identifier">examinees</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IRTExaminee</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;id##{no}&quot;</span>, <span class="ruby-identifier">responses</span>,<span class="ruby-node">&quot;00000-0000#{no}&quot;</span>, <span class="ruby-identifier">group</span>)
 71:         <span class="ruby-identifier">no</span> = <span class="ruby-identifier">no</span>.<span class="ruby-identifier">next</span>
 72:       <span class="ruby-keyword kw">end</span>
 73:     <span class="ruby-keyword kw">end</span>
 74: 
 75:     <span class="ruby-comment cmt"># 24 unique items on each of two forms and</span>
 76:     <span class="ruby-comment cmt"># 12 common items for a total of 60</span>
 77:     <span class="ruby-comment cmt"># items. Two groups specified</span>
 78:     <span class="ruby-comment cmt"># for multiple group estimation</span>
 79:     <span class="ruby-identifier">exam</span> = <span class="ruby-constant">IRTExam</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">examinees</span>, <span class="ruby-identifier">items</span>, <span class="ruby-value">2</span>)
 80:     
 81:     <span class="ruby-comment cmt"># Perform EM iterations for computing item parameter estimates</span>
 82:     <span class="ruby-comment cmt"># and probabilities of latent variable distributions for</span>
 83:     <span class="ruby-comment cmt"># groups 1 and 2. Scale points of latent variable distribution</span>
 84:     <span class="ruby-comment cmt"># after each M-step so the mean and s.d. in group 1 are</span>
 85:     <span class="ruby-comment cmt"># 0 and 1. Allow a maximum of 200 EM iterations.</span>
 86:     
 87:     <span class="ruby-identifier">model</span> = <span class="ruby-constant">IRTModel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">IRTModel</span><span class="ruby-operator">::</span><span class="ruby-constant">DICHOTOMOUS_2PL</span>)
 88:     <span class="ruby-identifier">algorithm</span> = <span class="ruby-constant">IRTAlgorithm</span>.<span class="ruby-identifier">new</span>
 89:     <span class="ruby-identifier">algorithm</span>.<span class="ruby-identifier">estimates_dist</span> = <span class="ruby-keyword kw">true</span>
 90:     <span class="ruby-identifier">algorithm</span>.<span class="ruby-identifier">scale_points</span> = <span class="ruby-keyword kw">true</span>
 91:     <span class="ruby-identifier">algorithm</span>.<span class="ruby-identifier">max_iter</span> = <span class="ruby-value">200</span>
 92:     
 93:     <span class="ruby-identifier">irt</span> = <span class="ruby-constant">IRT</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">exam</span>, <span class="ruby-identifier">model</span>, <span class="ruby-identifier">algorithm</span>)
 94:     
 95:     <span class="ruby-comment cmt">#estimates item paramters</span>
 96:     <span class="ruby-identifier">irt</span>.<span class="ruby-identifier">estimates_item_params</span>
 97:     <span class="ruby-identifier">irt</span>.<span class="ruby-identifier">estimates_examinee_theta</span>
 98:     <span class="ruby-comment cmt"># @irt.estimates_examinee_score</span>
 99: 
100:     <span class="ruby-comment cmt"># Write item parameter estimates, discrete latent</span>
101:     <span class="ruby-comment cmt"># variable distributions, and mean and s.d. of</span>
102:     <span class="ruby-comment cmt"># latent variable distributions.</span>
103:     <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">'./mondat.log'</span>, <span class="ruby-value str">'w'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
104:       <span class="ruby-identifier">file</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">irt</span>.<span class="ruby-identifier">to_s</span>
105:     <span class="ruby-keyword kw">end</span>
106: 
107:     <span class="ruby-comment cmt"># end of run</span>
108:     <span class="ruby-identifier">irt</span>.<span class="ruby-identifier">release</span>
109:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Private Instance methods</h3>

      <div id="method-M000043" class="method-detail">
        <a name="M000043"></a>

        <div class="method-heading">
          <a href="#M000043" class="method-signature">
          <span class="method-name">_get_responses</span><span class="method-args">(str_responses)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000043-source">
<pre>
     <span class="ruby-comment cmt"># File test/test_all.rb, line 122</span>
122:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_get_responses</span>(<span class="ruby-identifier">str_responses</span>)
123:     <span class="ruby-identifier">responses</span> = []
124:     <span class="ruby-identifier">str_responses</span>.<span class="ruby-identifier">each_char</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
125:       <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">res</span>
126:       <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'.'</span>
127:         <span class="ruby-identifier">responses</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IRTExam</span><span class="ruby-operator">::</span><span class="ruby-constant">MISSING_RESPONSE</span>
128:       <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'1'</span>
129:         <span class="ruby-identifier">responses</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IRTExam</span><span class="ruby-operator">::</span><span class="ruby-constant">CORRECT_RESPONSE</span>
130:       <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'0'</span>
131:         <span class="ruby-identifier">responses</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IRTExam</span><span class="ruby-operator">::</span><span class="ruby-constant">INCORRECT_RESPONSE</span>
132:       <span class="ruby-keyword kw">end</span>
133:     <span class="ruby-keyword kw">end</span>
134:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">responses</span>
135:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>